You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(web): a PDF page that mounts during a resize waits to paint - #41605
Resizing the file pane with a PDF open still drops frames after #41537. With a PDF of charts and images, a 6 second drag has 4 to 5 late frames and stalls of up to 67 ms.
To reproduce: open a PDF with heavy pages in the desktop app, scroll down a few pages, and drag the pane divider.
A page that has painted waits 150 ms for the width to settle before it paints again. A page that mounts during the drag has not painted, so it does not wait. It starts a pdf.js render on the main thread at once, and every later width change cancels and restarts that render.
Change
PdfViewer records the time of each change of the pane width. A page that mounts within 150 ms of one now waits the same 150 ms as the painted pages. Page loads at other times, such as the first open and scrolling, are not delayed.
Scope
This is a bug fix for a performance problem in one component: 19 changed lines outside tests. There is no issue for it. It is the second cause that I named under "Not checked" in #41537.
Verification
I found this in daily use of the desktop app on a 120 Hz MacBook display, where the resize was smoother after #41537 but not smooth.
Test. The new browser test narrows the pane once, which brings page 4 into the mounted range. On main it fails, because the viewer asks pdf.js for page 4 in the same commit as the resize. With the fix, page 4 is mounted but not requested, and it paints at the final width after the wait.
Measurement. I built apps/web from main (7182abe) and from this branch and mounted PdfViewer from each build in Chrome (GPU on, 60 Hz, device pixel ratio 2). The PDF has 12 pages with charts and images and starts on page 5. A script changed the pane width on every frame for 6 seconds. Each row shows two runs.
Drag
Build
Page renders started in the drag
Frames over 20 ms
Worst frame
480 to 740 px
main
4 / 4
4 / 4
33 / 50 ms
480 to 740 px
this PR
0 / 0
0 / 0
17 / 17 ms
760 to 1300 px
main
12 / 12
5 / 4
67 / 67 ms
760 to 1300 px
this PR
0 / 0
0 / 0
17 / 17 ms
Not fixed. A drag that pauses for more than 150 ms repaints the mounted pages at that pause, on main and with this PR. With a pause of 220 ms after every 20 frames, both builds started 40 renders. The late frames were 3 per drag on main and 1 per drag with this PR.
Desktop app. I ran the desktop dev build of this branch on the 120 Hz MacBook display and dragged the pane divider with a PDF open. The resize is smooth, about as smooth as the Word preview.
Not checked. I did not measure frame times at 120 Hz. There is no recording, because a screen capture does not show single late frames.
Claude Fable 5.2 with the Claude Agent SDK in T3 Code.
A page that entered the mounted range during a drag started a pdf.js
render at once, and every later width change cancelled and restarted it.
Only pages that had painted before waited for the width to settle.
The viewer now records the time of each width change, and a page that
mounts within 150 ms of one waits like the painted pages do.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Reviewing files that changed from the base of the PR and between ba883c0 and be07d6b.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
The PDF viewer records viewport-width changes and passes the latest resize time to its pages. Pages wait before requesting PDF data when a resize occurred within the previous 150 ms. A browser test checks page loading and canvas width after a resize.
Changes: PDF resize rendering
Layer / File(s)
Summary
Track and pass viewport resize time apps/web/src/components/files/PdfViewer.tsx
The resize observer records when clientWidth changes. PdfViewer passes the resize timestamp to each PdfPage.
Delay page requests after resize apps/web/src/components/files/PdfViewer.tsx, apps/web/src/components/files/PdfViewer.browser.test.tsx
PdfPage delays rendering after a recent resize, including for pages not yet painted. The browser test checks that a newly mounted page is not requested before the resize settles and that its canvas uses the settled width.
pingdotgg/t3code#39105: Adds the existing 150 ms wait for pages that have already painted; this change extends the wait to pages that mount during a resize.
Suggested reviewers:juliusmarminge, macroscopeapp
Merge Risk: Minimal · previous review ba883
This change makes PDF pages that mount during a pane resize wait for the width to settle before rendering, which reduces repeated renders during a drag. Initial open and scrolling are not delayed. No concrete merge-blocking risk was found.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: a PDF page that mounts during a pane resize now waits before painting, which matches the PdfViewer change that delays such pages by 150 ms. It uses the conventional co…
Description check
The description follows the template sections: Problem, Change, Scope, and Verification. The Problem section explains the frame drops and the reproduction steps. The Change section explains the 150 ms…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: a PDF page that mounts during a pane resize now waits before painting, which matches the PdfViewer change that delays such pages by 150 ms. It uses the conventional commit form with the fix(web) scope. The title is specific and accurate.
Full details: Description check
Explanation
The description follows the template sections: Problem, Change, Scope, and Verification. The Problem section explains the frame drops and the reproduction steps. The Change section explains the 150 ms wait for newly mounted pages. The Scope section says this is a bug fix and links the related PR #41537 as the prior work, but it says there is no issue for the bug and gives a reason. The Verification section names a focused browser test, gives measurements with the build and environment, and lists what was not checked. The description does not include screenshots, but the template asks for them only for UI changes, and this change is a performance fix with no visible UI change. The description also has no line stating which agent or model did the work beyond a short note, which the template requests, and it includes a model name that the template's sentence asks for, so this is covered.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
size:S10-29 changed lines (additions + deletions).takeover:needs-juliusTakeover done; route gate says Julius decidesvouch:unvouchedAuthor is not yet trusted in the VOUCHED list.
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Resizing the file pane with a PDF open still drops frames after #41537. With a PDF of charts and images, a 6 second drag has 4 to 5 late frames and stalls of up to 67 ms.
To reproduce: open a PDF with heavy pages in the desktop app, scroll down a few pages, and drag the pane divider.
A page that has painted waits 150 ms for the width to settle before it paints again. A page that mounts during the drag has not painted, so it does not wait. It starts a pdf.js render on the main thread at once, and every later width change cancels and restarts that render.
Change
PdfViewerrecords the time of each change of the pane width. A page that mounts within 150 ms of one now waits the same 150 ms as the painted pages. Page loads at other times, such as the first open and scrolling, are not delayed.Scope
This is a bug fix for a performance problem in one component: 19 changed lines outside tests. There is no issue for it. It is the second cause that I named under "Not checked" in #41537.
Verification
I found this in daily use of the desktop app on a 120 Hz MacBook display, where the resize was smoother after #41537 but not smooth.
Test. The new browser test narrows the pane once, which brings page 4 into the mounted range. On
mainit fails, because the viewer asks pdf.js for page 4 in the same commit as the resize. With the fix, page 4 is mounted but not requested, and it paints at the final width after the wait.Measurement. I built
apps/webfrommain(7182abe) and from this branch and mountedPdfViewerfrom each build in Chrome (GPU on, 60 Hz, device pixel ratio 2). The PDF has 12 pages with charts and images and starts on page 5. A script changed the pane width on every frame for 6 seconds. Each row shows two runs.Not fixed. A drag that pauses for more than 150 ms repaints the mounted pages at that pause, on
mainand with this PR. With a pause of 220 ms after every 20 frames, both builds started 40 renders. The late frames were 3 per drag onmainand 1 per drag with this PR.Desktop app. I ran the desktop dev build of this branch on the 120 Hz MacBook display and dragged the pane divider with a PDF open. The resize is smooth, about as smooth as the Word preview.
Not checked. I did not measure frame times at 120 Hz. There is no recording, because a screen capture does not show single late frames.
Claude Fable 5.2 with the Claude Agent SDK in T3 Code.
🤖 Generated with Claude Code